<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button class="btn1">发送get请求</button>
    <button class="btn2">发送post请求</button>
    <table>

    </table>
</body>

</html>
<script src="./js/jquery.js"></script>
<script>
    $('.btn1').on('click', function () {
        $.get('http://www.liulongbin.top:3006/api/getbooks', function (res) {
            for (var i in res.data) {
                const tr = document.createElement('tr')
                for (var j in res.data[i]) {
                    const td = document.createElement('td')
                    td.innerText = res.data[i][j];
                    tr.appendChild(td);
                }
                document.querySelector('table').appendChild('tr');
            }
        });
    })
    // 发送post请求
    $('.btn2').on('click', function () {
        $.post('http://liulongbin.top:3006/api/addbook', { username: '', password: '' }, (res) => {
            console.log(res);
        });
    })
</script>